import java.lang.Math;
import java.lang.Thread;

public class Test22 {
    public static void main(String[] args) {
        placeChoice p1 = new placeChoice(10, "北京");
        placeChoice p2 = new placeChoice(10, "上海");

        p1.start();
        p2.start();
    }
}

class placeChoice extends Thread {
    int count;

    String place;

    public placeChoice() {
        this(0, " ");
    }

    public placeChoice(int count, String place) {
        this.count = count;
        this.place = place;
    }

    @Override
    public void run() {
        while (count != 0) {
            System.out.println(place);

            try {
                int sleepTime = (int)(Math.random() * 10);
                Thread.sleep(sleepTime);
            } catch (InterruptedException e) {
                e.printStackTrace();
            } finally {
                count--;
            }
        }
    }
}
